<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>关注房源</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../../../taofang/plugins/bootstrap-3.3.7-dist/css/bootstrap.css">
    <link rel="stylesheet" href="../../../taofang/css/TenantCentre.css">
    <link rel="stylesheet" href="../../../taofang/css/home.css">
</head>
<body>
<script src="../../../taofang/plugins/jquery-3.4.1.js"></script>
<script src="../../../taofang/plugins/bootstrap-3.3.7-dist/js/bootstrap.js"></script>

<%@include file="top.jsp"%>

<div class="col-md-9 zy3">
    <table class="table table-hover">
        <thead>
        <tr>
            <th>房源编号</th>
            <th>租房类型</th>
            <th>房屋状态</th>
            <th>租金</th>
            <th>关注时间</th>
            <th>取消关注</th>
        </tr>
        </thead>
        <tbody id="tb">
        <c:forEach items="${concernList}" var="c" varStatus="loop">

            <tr>
                <td style="display: none">${c.id}</td>
                <td><a href="#">${c.houseId}</a></td>
                <td>${houseList[loop.count-1].rentType}</td>
                <td>${houseList[loop.count-1].houseState}</td>
                <td>${houseList[loop.count-1].rentMoney}/月</td>
                <td><fmt:formatDate value="${c.concernTime}" pattern="yyyy-MM-dd hh:MM:ss"></fmt:formatDate></td>
                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<sapn onclick="del(this,'${c.id}')" style="color: red" class="glyphicon glyphicon-heart-empty"></sapn></td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>

<%@include file="bottom.jsp"%>



<script>
    function del(obj,id) {
        if(confirm("确定取消关注么")) {
            let tbody = document.getElementById("tb");
            $.ajax({
                type: 'post',
                url: '/taofang/Attention/delAtt.action',
                data: {'id': id},
                success: function (data) {
                    if (data.code == 200) {
                        let tr = obj.parentElement.parentElement;
                        tbody.removeChild(tr);
                    } else {
                        alert("取消关注失败!");
                    }
                }
            })
        }else{

        }
    }
</script>

</body>
</html>
